package Thread;

/**
 * Created by sunwei on 2017/9/29
 * Time:17:14
 */
/*
继承线程类
 */
public class ThreadDemo1 extends Thread {
    private String name;
    //构造方法
    public ThreadDemo1(String name){
        this.name = name;
    }

    @Override
    public void run() {
        for(int i = 0; i <5 ; i++) {
            System.out.println(name+"运行:"+i);
            try {
                sleep((int) Math.random() * 10);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
